package xin.marcher.module.label.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import xin.marcher.module.common.core.PageResult;
import xin.marcher.module.label.domain.dto.*;
import xin.marcher.module.label.domain.entity.*;
import xin.marcher.module.label.domain.request.*;

import java.util.List;

/**
 * 
 */
@Mapper(componentModel = "spring")
public interface LabelConverter {

    @Mapping(target = "updateUser", source = "operateUser")
    LabelGroupDO convertLabelGroupDO(LabelGroupRequest request);

    List<LabelGroupDTO> convertLabelGroupDOS(List<LabelGroupDO> labelGroupDOS);

    @Mapping(target = "updateUser", source = "operateUser")
    LabelDO convertLabelDO(LabelRequest request);

    @Mappings({
            @Mapping(target = "content", source = "records"),
            @Mapping(target = "totalElements", source = "total"),
            @Mapping(target = "number", source = "current"),
            @Mapping(target = "totalPages", source = "pages"),
    })
    PageResult<LabelDTO> convertLabelDOPage(Page<LabelDO> selectPage);

    @Mapping(target = "updateUser", source = "operateUser")
    CategoryLabelGroupRelationDO convertCategoryLabelGroupRelation(CategoryLabelGroupRelastionRequest request);

    List<CategoryLabelGroupRelationDTO> convertLabelGroupRelationDTOS(List<CategoryLabelGroupRelationDO> categoryLabelGroupRelationDOS);

    List<LabelDTO> convertLabelDOS(List<LabelDO> labelDOS);

    @Mapping(target = "updateUser", source = "operateUser")
    FrontCategoryLabelRelationDO convertFrontCategoryLabelGroupRelation(FrontCategoryLabelRelationRequest request);

    List<FrontCategoryLabelRelationDTO> convertFrontLabelGroupRelationDTOS(List<FrontCategoryLabelRelationDO> frontCategoryLabelRelationDTOS);

    @Mapping(target = "updateUser", source = "operateUser")
    List<ProductLabelRelationDO> convertProductLabelRelations(List<ProductLabelRelationRequest> request);

    List<ProductLabelRelationDTO> convertProductLabelRelationDTOS(List<ProductLabelRelationDO> productLabelRelationDTOS);

}
